﻿using System;
using System.Linq;
using Skyper.View;
using Skyper.Model;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Collections.Generic;
using Skyper.View.Panorama;

namespace Skyper.ViewModel {
	public class ContactsPanoramaViewModel : PanoramaViewModel {
		#region Fields
		private ContactModel selectedContact;
		#endregion
		#region Constructor
		public ContactsPanoramaViewModel() {
			this.Title = "Contacts";
			this.Content = new ContactsView();
			App.Skype.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Skype_PropertyChanged);
		}
		#endregion
		#region Private
		private void Skype_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) {
			if (e.PropertyName == "Contacts") {
				this.OnPropertyChanged(e.PropertyName);
			}
		}
		#endregion
		#region Property
		/// <summary>
		/// Gets the available contacts for viewing.
		/// </summary>
		/// <value>The available.</value>
		public IEnumerable<ContactModel> Contacts {
			get {
				return (from n in App.Skype.Contacts
						select n).ToArray();
			}
		}
		/// <summary>
		/// Gets or sets the selected contact.
		/// </summary>
		/// <value>The selected contact.</value>
		public ContactModel SelectedContact {
			get {
				return this.selectedContact;
			}
			set {
				if (this.selectedContact != value) {
					this.selectedContact = value;
					this.OnPropertyChanged("SelectedContact");
				}
			}
		}
		#endregion
	}
}
